#ifndef __PUBLICTRANSPORTSGQUERY__
#define __PUBLICTRANSPORTSGQUERY__

#include <e32base.h>
#include "CActiveHelper.h"
#include <euserhl.h>
#include <Function.h>
#include "ArrivalTimeQuery.h"
#include <es_sock.h>

class CPublictransportsgQuery;

class CPublictransportsgSession : public MActiveHelperCallback<RTimer*>
	{
	
public:
	RArray<CPublictransportsgQuery*> iPublictransportsgQueries;
	// constructors and destructor
	CPublictransportsgSession();
	RHTTPSession iHTTPSession;
	void SetConnectionInfo(const RConnection& aConnection, const RSocketServ& aSocketServ);
	static CPublictransportsgSession* NewL();
	static CPublictransportsgSession* NewLC();
	RTimer iPublicTransportTimeoutTimer;
	CActiveHelper<RTimer*>* iPublicTransportTimeoutTimerHelper;
	void ConstructL();
	virtual ~CPublictransportsgSession();
	void MActiveHelperCallbackRunL(CActiveHelper<RTimer*>* aActiveHelper, RTimer* aTimer);
	TInt MActiveHelperCallbackRunError(CActiveHelper<RTimer*>* aActiveHelper, RTimer* aTimer, TInt aError);
	void MActiveHelperCallbackDoCancel(CActiveHelper<RTimer*>* aActiveHelper, RTimer* aTimer);
	};



class CPublictransportsgQuery : public CArrivalTimeQuery, public MHTTPTransactionCallback
	{
public:
	TServiceRequestStatus iRequestStatus;
private:
	CPublictransportsgSession* iSession;
	HBufC8* iStop;
	RBuf8 iBody;
	RHTTPTransaction iTransaction;
	void ConstructL();
	TBool iCallbacksCompleted;
	TInt iLastError;
	LManagedPtr< scalp::CFunction<void(CPublictransportsgQuery*, const TDesC8&, const TDesC8&, TServiceRequestStatus, const TDesC&, const TDesC8&, const TDesC8&)> > iCallback;

public:
    virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
    virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
	void SubmitL();
	TBool Pending() const;
	void Cancel();
	static CPublictransportsgQuery* NewLC();
	static CPublictransportsgQuery* NewL();
	virtual ~CPublictransportsgQuery();
	};


#endif /* __PUBLICTRANSPORTSGQUERY__ */
